Using High-Level Memory Functions with PXI

This section contains information specific to the Windows product.

High-level memory functions allow you to access memory through simple function calls. There is no need to map memory to a window. Instead, when high-level memory functions are used, memory mapping and direct register access are automatically done.

High-level memory functions are easier to use; however, the trade-off is speed. Since these functions encompass mapping of memory space and direct register access, the associated overhead slows program execution time. If speed is required, use the low-level memory functions discussed in Using Low-Level Memory Functions with PXI.

Programming the Registers

High-level memory functions include the viIn and viOut functions for transferring 8-, 16-, 32-, or 64-bit values, as well as the viMoveIn and viMoveOut functions for transferring 8-, 16-, 32-, or 64-bit blocks of data into or out of local memory.

High-Level Memory Functions

The table below summarizes the high-level memory functions.

Function

Description

viIn8(vi, space, offset, val8);

Reads 8 bits of data from the specified offset.

viIn16(vi, space, offset, val16);

Reads 16 bits of data from the specified offset.

viIn32(vi, space, offset, val32);

Reads 32 bits of data from the specified offset.

viIn64(vi, space, offset, val64);

Reads 64 bits of data from the specified offset.

viOut8(vi, space, offset, val8);

Writes 8 bits of data to the specified offset.

viOut16(vi, space, offset, val16);

Writes 16 bits of data to the specified offset.

viOut32(vi, space, offset, val32);

Writes 32 bits of data to the specified offset.

viOut64(vi, space, offset, val64);

Writes 64 bits of data to the specified offset.

viMoveIn8(vi, space, offset, length, buf8);

Moves an 8-bit block of data from the specified offset to local memory.

viMoveIn16(vi, space, offset, length, buf16);

Moves a 16-bit block of data from the specified offset to local memory.

viMoveIn32(vi, space, offset, length, buf32);

Moves a 32-bit block of data from the specified offset to local memory.

viMoveIn64(vi, space, offset, length, buf32);

Moves a 64-bit block of data from the specified offset to local memory.

viMoveOut8(vi, space, offset, length, buf8);

Moves an 8-bit block of data from local memory to the specified offset.

viMoveOut16(vi, space, offset, length, buf16);

Moves a 16-bit block of data from local memory to the specified offset.

viMoveOut32(vi, space, offset, length, buf32);

Moves a 32-bit block of data from local memory to the specified offset.

viMoveOut64(vi, space, offset, length, buf32);

Moves a 64-bit block of data from local memory to the specified offset.

Using viIn and viOut

When using the viIn and viOut high-level memory functions to program to the device registers, all you need to specify is the session identifier, address space, and the offset of the register. Memory mapping is done for you. For example, in this function:

viIn32(vi, space, offset, val32);

vi is the session identifier and offset is used to indicate the offset of the memory to be mapped. Offset is relative to the location of this device's memory in the given address space. The space parameter determines which memory location to map. Valid space values for PXI devices are:

  • VI_PXI_CFG_SPACE  -  Address the PCI configuration space.
  • VI_PXI_BAR0_SPACE - VI_PXI_BAR5_SPACE  -  Address the specified Base Address Register PCI memory or I/O space.
  • VI_PXI_ALLOC_SPACE -  Access physical locally allocated memory.

The val32 parameter is a pointer to where the data read will be stored.
If instead you write to the registers via the viOut32 function, the val32 parameter is a pointer to the data to write to the specified registers. If the device specified by vi does not have memory in the specified address space, an error is returned.

Using viMoveIn and viMoveOut

You can use the viMoveIn and viMoveOut high-level memory functions to move blocks of data to or from local memory. Specifically, the viMoveIn function moves an 8-, 16-, 32-, or 64-bit block of data from the specified offset to local memory, and the viMoveOut functions moves an 8-, 16-, 32-, or 64-bit block of data from local memory to the specified offset. Again, the memory mapping is done for you. For example, in this function:

viMoveIn32(vi, space, offset, length, buf32);

vi is the session identifier and offset is used to indicate the offset of the memory to be mapped. offset is relative to the location of this device's memory in the given address space. The space parameter determines which memory location to map the space, and the length parameter specifies the number of elements to transfer (8-, 16-, 32-, or 64-bits).

The buf32 parameter is a pointer to where the data read will be stored.
If instead you write to the registers via the viMoveOut32 function, the buf32 parameter is a pointer to the data to write to the specified registers.

High-Level Memory Access Example

The VisaHighLevelMemoryAccess function in the PXIVisaSample program demonstrates how to use viIn32 and viMoveIn32 high-level memory functions.